package de.jmda.core.util;

import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import de.jmda.core.util.RuntimeUtil;


public class JUTRuntimeUtil
{
	private String callingClassPrivateConstructor;
	private String callingClassPrivateMethod;
	
	private String callingMethodPrivateConstructor;
	private String callingMethodPrivateMethod;
	
	private class PrivateClass
	{
		private PrivateClass()
		{
			callingClassPrivateConstructor = RuntimeUtil.getCallingClass().getName();
			callingMethodPrivateConstructor = RuntimeUtil.getCallingMethodName();
		}
		
		private void privateMethod()
		{
			callingClassPrivateMethod = RuntimeUtil.getCallingClass().getName();
			callingMethodPrivateMethod = RuntimeUtil.getCallingMethodName();
		}
	}
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception
	{
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception
	{
	}

	@Before
	public void setUp() throws Exception
	{
	}

	@After
	public void tearDown() throws Exception
	{
	}
	
	@Test
	public void test()
	{
		assertEquals(this.getClass(), RuntimeUtil.getThisClass());
		assertEquals("test", RuntimeUtil.getThisMethodName());
		
		PrivateClass privateClass = new PrivateClass();
		privateClass.privateMethod();

		assertEquals(PrivateClass.class.getName(), callingClassPrivateConstructor);
		assertEquals("<init>", callingMethodPrivateConstructor);
		assertEquals(JUTRuntimeUtil.class.getName(), callingClassPrivateMethod);
		assertEquals("test", callingMethodPrivateMethod);
	}
}